package com.ketai.web;

import com.ketai.common.MessageConstant;
import com.ketai.common.Result;
import com.ketai.util.FileUploadUtil;
import com.ketai.util.SendUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.IOException;
import java.util.Collection;

/**
 * @Author:长沙科泰梦想学院-蓝色小药丸
 * @Mission:打造演说·创客型跨境电商与互联网人才
 * @Description:
 * @Date:Create In 2022/8/6 22:31
 **/
@WebServlet("/admin/fileupload")
@MultipartConfig
public class FileUploadServlet extends HttpServlet {


    @Override
    protected void service (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
         String opr= req.getParameter("opr");
         if ("one".equals(opr)) {
             Part  part=req.getPart("file");
            String src= FileUploadUtil.fileUploadOSS(part);
             System.out.println(src);
            //文件上传成功
             SendUtil.Sendjson(resp,Result.ok(MessageConstant.FILE_UPLOAD_SUCCESS,src));
         }



    }
}
